import os
import rtconfig
from building import *

cwd = GetCurrentDir()

# add general drivers
# CubeMX_Config/Src/stm32f7xx_hal_msp.c
src = Split('''
sys_init.c
CubeMX_Config/Src/system_stm32f7xx.c
assembly/startup_stm32f767xx.s
''')

if GetDepend(['BSP_USING_ETH']):
    src += ['ports/phy_reset.c']

if GetDepend(['BSP_USING_QSPI_FLASH']):
    src += ['ports/drv_qspi_flash.c']

if GetDepend('BSP_USING_SDIO'):
    src += ['sd/sd_task.c']

if GetDepend('RT_USING_SERIAL'):
    src += ['uart/uart.c']

path =  [cwd]
path += [cwd + '/CubeMX_Config/Inc']
path += [cwd + '/ports']

CPPDEFINES = ['STM32F767xx']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)

group = group + SConscript('Drivers/SConscript')

if GetDepend('BSP_USING_FMC_SDRAM'):
    group = group + SConscript('sdram/SConscript')

if GetDepend('BSP_USING_GUI'):
    group = group + SConscript('gui/SConscript')

if GetDepend('BSP_USING_TOUCH'):
    group = group + SConscript('touch/SConscript')


Return('group')
